package org.example.controller;

import org.example.entity.Order;
import org.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/orders")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping
    public boolean add(@RequestBody Order order){
        orderService.asynCreateOrder(order);
        return true;
    }

    @GetMapping("/sk")
    public String sk(Long bookId,Integer userId){
        boolean success=orderService.secondsKill(bookId,userId);
        return success ? "秒杀成功":"秒杀失败";
    }
}
